package com.test.proxy.jdk;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

//代理类
public class MyInvocationHandler implements InvocationHandler {

    //目标对象,也就是代理类中的真实对象
    private final Object target;

    public MyInvocationHandler(Object target){
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("-----前置通知处理-----");
        Object result = method.invoke(target,args);
        System.out.println("--------后置通知处理------");
        return result;
    }
}
